<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/test.css">
<title>Regist</title>
<script>
function  goLogin()
{
	window.location.assign("/ImageTest/login.jsp");
}

function validate()
{
	var username = document.getElementById("username_1").value;
	var password = document.getElementById("password_1").value;
	var repassword = document.getElementById("repassword_1").value;
	if(username == "" || password == "" || repassword == "")
	{
		alert("用户名或者密码不能为空！");
		return false;
	}
	
	if(repassword.length <6 || repassword.length>10)
	{
		alert("密码不能小于6位或者大于10位");
		return false;
	}
	
	if(repassword.length <6 || repassword.length>10)
	{
		alert("密码不能小于6位或者大于10位");
		return false;
	}
	
	if(password != repassword)
	{
		alert("两次输入的密码不同，请重新输入！");
		return false;
	}
	
	return true;
}
</script>

</head>
<body>

<%! String currentUser = null; %>
<%
//判断是否已经有用户登录
	currentUser = (String)session.getAttribute("currentUser");
	if(null != currentUser)
	{
		out.print("<p id='welcomeInfo'> 当前登录用户："+currentUser+" <a href='/ImageTest/test.jsp'>退出当前用户</a></p>");
	}
	
%>
<!-- 判断用户注册是否成功 -->
<%!String bRegist = null; %>
<%
	bRegist = (String)request.getAttribute("regist");
	//System.out.println(bRegist);
%>
<%
if(bRegist != null){
	if("false".equals(bRegist)) {%>
<p id=first>注册失败 请重新注册！</p>
<%}}%>

<%
if(bRegist != null){
	if("hasRegisted".equals(bRegist)) {%>
<p id=first >用户名已经被注册 请选择其他用户名！</p>
<%}}%>

<!-- 判断用户注册是否成功 -->

<div id="header"></div>

<ul id="nav">
<li><a href="/ImageTest/index.jsp">首页</a></li>
<li><a href="/ImageTest/viewImage.jsp">看图片</a></li>
<li><a href="/ImageTest/upload_file.jsp">上传图片</a></li>
<li><a href="/ImageTest/login.jsp">登录</a></li>
<li><a href="/ImageTest/regist.jsp">注册用户</a></li>
<li><a href="/ImageTest/administor.jsp">管理员</a></li>
</ul>

<div id="content">
<form onsubmit="return validate()" action="regist_svr" method="post">
<table id="content_table" align="center">
<tr>
<td>用  户  名:</td>
<td><input id="username_1" type="text"  name="username"/></td>
</tr>
<tr>
<td>密	码:</td>
<td><input id="password_1" type="password"  name="password"/></td>
</tr>
<tr>
<td>重复密码:</td>
<td><input id="repassword_1"  type="password"  name="repassword"/></td>
</tr>
<tr>
<td><input type="submit"  name="submit" value="注册"/></td>
<td><input type="reset"  name="reset" value="重置"/></td>
</tr>
</table>
</form>
</div>
<p id="last">如果已经有用户名和密码，清单击登陆 <input type="button" value="login" name="login" onclick="goLogin()"></input></p>

</body>
</html>